package com.geely.design.pattern.behavioral.interpreter;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {
    public static void main(String[] args) {
        String inputStr = "6 100 11 + *";
        MyExpressionParser parser = new MyExpressionParser();
        int parse = parser.parse(inputStr);
        System.out.println(parse);
    }

    @org.junit.Test
    public void test_pattern() {
        Pattern pattern = Pattern.compile("^a{0,9}$");
        Matcher matcher = pattern.matcher("aabbaaccaaaa");
    }

    @org.junit.Test
    public void test_spelparser() {
        ExpressionParser parser = new SpelExpressionParser();
        Expression expression = parser.parseExpression("1 + 2 * 3");
        Object value = expression.getValue();
        System.out.println(value);
    }

}
